﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.Entities.BaseInfo.Points
{
    /// <summary>
    /// 温度测点
    /// </summary>
    public class TemperaturePoint : Point
    {

        protected TemperaturePoint()
        {

        }

        public TemperaturePoint(Guid id, string name, string nameen) : base(id, name, nameen)
        {

        }

        /// <summary>
        /// 取值范围-最低
        /// </summary>
        [NotMapped]
        public double MinValue { get; set; }

        /// <summary>
        /// 取值范围-最高
        /// </summary>
        [NotMapped]
        public double MaxValue { get; set; }

        /// <summary>
        /// 小数点位数
        /// </summary>
        [NotMapped]
        public double Digits { get; set; }

        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }

    }
}
